package com.lyf.baoxian.fragment;

import android.graphics.Color;
import android.os.Bundle;
import android.os.SystemClock;
import android.support.v4.widget.SwipeRefreshLayout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.lyf.baoxian.R;
import com.lyf.baoxian.adapter.BaoDanAdapter;
import com.lyf.baoxian.bean.CustomerBaoDan;
import com.lyf.baoxian.utils.MyMethod;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by 刘亚飞 on 2016/11/30.
 */

public class TouBaoFragment extends BaseFragment {
    /*@Bind(R.id.table_title)
    ViewGroup table_title;*/
    @Bind(R.id.list_toubao)
    ListView list_toubao;
    @Bind(R.id.swip)
    SwipeRefreshLayout swip;
    @Bind(R.id.et_date)
    TextView et_date;

    private List<CustomerBaoDan> datas;

    @Override
    protected void afterCreate(Bundle savedInstanceState) {
        initData();
//        table_title.setBackgroundColor();
//        LinearLayout ll = (LinearLayout) table_title.findViewById(R.id.ll_title);
        BaoDanAdapter adapter = new BaoDanAdapter(mActivity);
        adapter.setDatas(datas);
        list_toubao.setAdapter(adapter);

    }

    /**
     * 请求数据
      */
    private void initData() {
        datas = new ArrayList<>();
        swip.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                SystemClock.sleep(300);
                swip.setRefreshing(false);
            }
        });

        et_date.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                MyMethod.showDateDiaog(mActivity,et_date);

            }
        });
        datas.add(new CustomerBaoDan("2016.11.1","张三","套餐1","成功"));
        datas.add(new CustomerBaoDan("2016.11.3","笑傲","套餐2","失败"));

    }

    @Override
    protected View addLayout(LayoutInflater inflater) {
        View view = inflater.inflate(R.layout.fragment_toubao, null);
        return view;
    }

    @Override
    public void onDestroy() {
        ButterKnife.unbind(this);
        super.onDestroy();
    }
}
